home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / js / search.js < prev    next >
Encoding:
JavaScript  |  2007-12-04  |  34.4 KB  |  1,170 lines

  1. // ********************************************************************************************************************
  2. // Search Functions
  3. // ********************************************************************************************************************
  4.  
  5. var globalHightLightColor = "";
  6. var globalHightLightColorCell1 = '';
  7. var globalHightLightColorCell2 = '';
  8. var globalHightLightColorCell3 = '';
  9.  
  10. function issueItem() {
  11.   var year;
  12.   var nos = new Array();
  13. }
  14.  
  15. function nodeResultItem() {
  16.   var year = '';
  17.   var nr = '';
  18.   var category = '';
  19.   var title = '';
  20.   var description = '';
  21.   var link = '';
  22. }
  23.  
  24. var smallLetters = 'abcdefghijklmnopqrstuvwxyz';
  25. var bigLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  26. var xmlDocLocal = null;
  27. var xmlDocGlobal = null;
  28. var availableCategories = new Array();
  29. var availableIssues = new Array();
  30. var sorting = 1;
  31. var globalResultNodes = null;
  32. var localResultNodes = null;
  33.  
  34. function sortByTitleDESC (a, b) {
  35.   var valueA = a.title.toLowerCase();
  36.   var valueB = b.title.toLowerCase();
  37.   return ((valueA < valueB) ? -1 : ((valueA > valueB) ? 1 : 0));
  38. }
  39.  
  40. function sortByTitleASC (a, b) {
  41.   var valueA = a.title.toLowerCase();
  42.   var valueB = b.title.toLowerCase();
  43.   return ((valueA < valueB) ? 1 : ((valueA > valueB) ? -1 : 0));
  44. }
  45.  
  46. function sortByCategoryDESC (a, b) {
  47.   var valueA = a.category.toLowerCase();
  48.   var valueB = b.category.toLowerCase();
  49.   return ((valueA < valueB) ? -1 : ((valueA > valueB) ? 1 : 0));
  50. }
  51.  
  52. function sortByCategoryASC (a, b) {
  53.   var valueA = a.category.toLowerCase();
  54.   var valueB = b.category.toLowerCase();
  55.   return ((valueA < valueB) ? 1 : ((valueA > valueB) ? -1 : 0));
  56. }
  57.  
  58. function sortByDescriptionDESC (a, b) {
  59.   var valueA = a.description.toLowerCase();
  60.   var valueB = b.description.toLowerCase();
  61.   return ((valueA < valueB) ? -1 : ((valueA > valueB) ? 1 : 0));
  62. }
  63.  
  64. function sortByDescriptionASC (a, b) {
  65.   var valueA = a.description.toLowerCase();
  66.   var valueB = b.description.toLowerCase();
  67.   return ((valueA < valueB) ? 1 : ((valueA > valueB) ? -1 : 0));
  68. }
  69.  
  70. function sortByIssueDESC (a, b) {
  71.   var yearA = parseInt(a.year);
  72.   var yearB = parseInt(b.year);
  73.   var nrA = parseInt(a.nr);
  74.   var nrB = parseInt(b.nr);
  75.   if (yearA == yearB) {
  76.     return ((nrA > nrB) ? 1 : ((nrA < nrB) ? -1 : 0));
  77.   }
  78.   else {
  79.     return ((yearA > yearB) ? 1 : ((yearA < yearB) ? -1 : 0));
  80.   }
  81. }
  82.  
  83. function sortByIssueASC (a, b) {
  84.   var yearA = parseInt(a.year);
  85.   var yearB = parseInt(b.year);
  86.   var nrA = parseInt(a.nr);
  87.   var nrB = parseInt(b.nr);
  88.   if (yearA == yearB) {
  89.     return ((nrA < nrB) ? 1 : ((nrA > nrB) ? -1 : 0));
  90.   }
  91.   else {
  92.     return ((yearA < yearB) ? 1 : ((yearA > yearB) ? -1 : 0));
  93.   }
  94. }
  95.  
  96. function doSort(nodesArray) {
  97.     switch (sorting) {
  98.       case 1:
  99.         nodesArray.sort(sortByTitleDESC);
  100.         break;
  101.       case 2:
  102.         nodesArray.sort(sortByTitleASC);
  103.         break;
  104.       case 3:
  105.         nodesArray.sort(sortByCategoryDESC);
  106.         break;
  107.       case 4:
  108.         nodesArray.sort(sortByCategoryASC);
  109.         break;
  110.       case 5:
  111.         nodesArray.sort(sortByDescriptionDESC);
  112.         break;
  113.       case 6:
  114.         nodesArray.sort(sortByDescriptionASC);
  115.         break;
  116.       case 7:
  117.         nodesArray.sort(sortByIssueDESC);
  118.         break;
  119.       case 8:
  120.         nodesArray.sort(sortByIssueASC);
  121.         break;
  122.     }
  123. }
  124.  
  125. function setSorting(value, type) {
  126.     if (sorting == value) {
  127.       sorting = value+1;
  128.     }
  129.     else {
  130.       if (sorting == value+1) {
  131.         sorting = value;
  132.       }
  133.       else {
  134.         sorting = value;
  135.       }
  136.     }
  137.  
  138.     if (type == 1) {
  139.         doSort(localResultNodes);
  140.         var html = getResultHTML(localResultNodes, 1);
  141.         var searchContent = document.getElementById('searchContentLocal');
  142.         if (searchContent != null) {
  143.           searchContent.innerHTML = html;
  144.           resizeIFrame();
  145.           redrawResultsTable();
  146.         }
  147.     }
  148.     else {
  149.         doSort(globalResultNodes);
  150.         var html = getResultHTML(globalResultNodes, type);
  151.         var searchContent = document.getElementById('searchContentGlobal');
  152.         if (searchContent != null) {
  153.           searchContent.innerHTML = html;
  154.           resizeIFrame();
  155.           redrawResultsTable();
  156.         }
  157.     }
  158. }
  159.  
  160. function existsInResults(arrResults, node) {
  161.   var rN = null;
  162.   for (var i=0; i<arrResults.length; i++) {
  163.     rN = arrResults[i];
  164.     if (rN.year == node.year && rN.nr == node.nr && rN.category == node.category && rN.title == node.title && rN.description == node.description && rN.link == node.link) {
  165.       return true;
  166.     }
  167.   }
  168.   return false;
  169. }
  170.  
  171. function getResultArray(resultNodes) {
  172.   var issueNode, resultNode;
  173.   var result = new Array();
  174.  
  175.   for (var i=0; i<resultNodes.length; i++) {
  176.     resultNode = resultNodes[i];
  177.  
  178.     if (resultNode.nodeName != 's') {
  179.       resultNode = resultNode.parentNode;
  180.     }
  181.     issueNode = resultNode.parentNode;
  182.     var itemNode = new nodeResultItem();
  183.     itemNode.year = issueNode.getAttribute('year');
  184.     itemNode.nr = issueNode.getAttribute('nr');
  185.     itemNode.category = resultNode.getAttribute('c');
  186.     if (resultNode.getElementsByTagName('t')[0].hasChildNodes) {
  187.        itemNode.title = resultNode.getElementsByTagName('t')[0].firstChild.nodeValue;
  188.     }
  189.     else {
  190.          itemNode.title = '';
  191.     }
  192.     if (resultNode.getElementsByTagName('k')[0].hasChildNodes) {
  193.        itemNode.description = resultNode.getElementsByTagName('k')[0].firstChild.nodeValue;
  194.     }
  195.     else {
  196.          itemNode.description = '';
  197.     }
  198.     if (resultNode.getElementsByTagName('a')[0].hasChildNodes) {
  199.        itemNode.link = resultNode.getElementsByTagName('a')[0].firstChild.nodeValue;
  200.     }
  201.     else {
  202.          itemNode.link = '';
  203.     }
  204.     if (!existsInResults(result, itemNode)) {
  205.       result.push(itemNode);
  206.     }
  207.   }
  208.   return result;
  209. }
  210.  
  211. function getResultHTML(resultItems, type) {
  212.   var resultNode, issueNode, category, title, description, link, year, nr, issueText, aStart, aEnd;
  213.   var color;
  214.   var imgTitle = '';
  215.   var imgCategory = '';
  216.   var imgDescription = '';
  217.   var imgIssue = '';
  218.   switch (sorting) {
  219.     case 1:
  220.       imgTitle = '<img src="images/arrows/arrowDown.gif" width="17" height="13" />';
  221.       break;
  222.     case 2:
  223.       imgTitle = '<img src="images/arrows/arrowUp.gif" width="17" height="13"  />';
  224.       break;
  225.     case 3:
  226.       imgCategory = '<img src="images/arrows/arrowDown.gif" width="17" height="13" />';
  227.       break;
  228.     case 4:
  229.       imgCategory = '<img src="images/arrows/arrowUp.gif" width="17" height="13" />';
  230.       break;
  231.     case 5:
  232.       imgDescription = '<img src="images/arrows/arrowDown.gif" width="17" height="13" />';
  233.       break;
  234.     case 6:
  235.       imgDescription = '<img src="images/arrows/arrowUp.gif" width="17" height="13" />';
  236.       break;
  237.     case 7:
  238.       imgIssue = '<img src="images/arrows/arrowDown.gif" width="17" height="13" />';
  239.       break;
  240.     case 8:
  241.       imgIssue = '<img src="images/arrows/arrowUp.gif" width="17" height="13" />';
  242.       break;
  243.   }
  244.  
  245.   doSort(resultItems);
  246.  
  247.   var result = '<div>';
  248.  
  249.   if( resultItems.length > 0 ) {
  250.  
  251.       result += '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="searchResultsTableHeader">';
  252.       result += '<tr id="searchHeader">';
  253.  
  254.       result += '<td id="firstSearchColumn" width="141"><div><a href="javascript: void(0);" style="padding-left: 5px;" onclick="setSorting(1, ' + type + ');">Titel</a></div><div class="sortImage">' + imgTitle + '</div></td>';
  255.       result += '<td id="secondSearchColumn" width="525" class="borderLeft"><div><a href="javascript: void(0);" style="padding-left: 5px;" onclick="setSorting(5, ' + type + ');" class="searchCategory">Beschreibung</a></div><div class="sortImage">' + imgDescription + '</div></td>';
  256.       result += '<td id="thirdSearchColumn" class="right"><div><a href="javascript: void(0);" style="padding-left: 1px;" onclick="setSorting(7, ' + type + ');" class="searchCategory">Ausgabe</a></div><div class="sortImage">' + imgIssue + '</div></td>';
  257.  
  258.       result += '</tr>';
  259.       result += '</table>';
  260.  
  261.       result += '<div style="width: 100%; overflow: auto; background: white;" id="searchResultsDiv"><table cellpadding="0" cellspacing="0" border="0" class="searchResultsTable" id="searchResultsTable">';
  262.  
  263.       var onClickGoTo = "";
  264.  
  265.       for (var i=0; i<resultItems.length; i++) {
  266.         resultItem = resultItems[i];
  267.  
  268.         if (parseInt(resultItem.year) == parseInt(actYear) && parseInt(resultItem.nr) == parseInt(actNo)) {
  269.           issueText = resultItem.year + ' - ' + resultItem.nr;
  270.           aStart = '<a href="javascript: void(0);" onclick="switch_iframe(\'' + resultItem.link + '\');">';
  271.           aEnd = '</a>';
  272.  
  273.           onClickGoTo = "javascript:switch_iframe('" + resultItem.link + "');";
  274.         }
  275.         else {
  276.           issueText = resultItem.year + ' - ' + resultItem.nr;
  277.           aStart = '';
  278.           aEnd = '';
  279.           onClickGoTo = "javascript:switch_iframe('" + resultItem.link + "');";
  280.         }
  281.  
  282.         if (i%2 == 0) {
  283.           color = "One";
  284.         }
  285.         else {
  286.           color = "Two";
  287.         }
  288.  
  289.         result += '<tr valign="top" class="row' + color + '">';
  290.  
  291. //        result += '<td width="130">' + aStart + resultItem.title + aEnd + '</td>';
  292.         if (sorting == 1 || sorting == 2) {
  293.           result += '<td width="130" class="row' + color + 'Sort" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + resultItem.title + '</td>';        
  294.         }
  295.         else {
  296.           result += '<td width="130" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + resultItem.title + '</td>';
  297.         }
  298.  
  299.         var tempTxt = ' ';
  300.         if (resultItem.description.length > 0) {
  301.           var tempTxt = resultItem.description;
  302.         }
  303.          
  304.         if (sorting == 5 || sorting == 6) {         
  305.           result += '<td width="512" class="borderLeft row' + color + 'Sort" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + tempTxt + '</td>';
  306.         }
  307.         else {
  308.           result += '<td width="512" class="borderLeft" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + tempTxt + '</td>';
  309.         }
  310.  
  311.         if (sorting == 7 || sorting == 8) {
  312.           result += '<td width="79" class="right row' + color + 'Sort" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + issueText.replace(/ /g, "").replace(/-/g, "/") + '</td>';
  313.         }
  314.         else {
  315.           result += '<td width="79" class="right" onClick="' + onClickGoTo + '" onMouseOver="javascript:hightLightLine( this );" onMouseOut="javascript:unHightLightLine( this );">' + issueText.replace(/ /g, "").replace(/-/g, "/") + '</td>';
  316.         }
  317.  
  318.         result += '</tr>';
  319.       }
  320.  
  321.       result += '</table>';
  322.  
  323.   } else {
  324.       result += '<br /><br /><br /><h3 class="searchResults">Keine Elemente gefunden</h3>';
  325.   }
  326.  
  327.   result += '</div>';
  328.  
  329.   return result;
  330. }
  331.  
  332. /**
  333.  * executeInnerHTMLJavaScript
  334.  *
  335.  * @param {Element} element
  336.  */
  337.  function executeInnerHTMLJavaScript( element ) {
  338.  
  339.      if( element != null ) {
  340.  
  341.          var scriptTags = element.getElementsByTagName( "script" );
  342.  
  343.          if( scriptTags != null && scriptTags.length > 0 ) {
  344.  
  345.              for( var loop = 0; loop < scriptTags.length; loop++ ) {
  346.                  eval( scriptTags[loop].text );
  347.              }
  348.          }
  349.      }
  350.  }
  351.  
  352.  function setAllTableCells(parentRow, className) {
  353.    var cells = parentRow.getElementsByTagName('td');
  354.    for (i=0; i<cells.length; i++) {
  355.     switch (i) {
  356.       case 0:
  357.         globalHightLightColor1 = cells[0].className;
  358.         break;
  359.       case 1:
  360.         globalHightLightColor2 = cells[1].className;
  361.         break;
  362.       case 2:
  363.         globalHightLightColor3 = cells[2].className;
  364.         break;
  365.     }
  366.      
  367.      cells[i].className = className;
  368.    }
  369.  }
  370.  
  371.  function restorAllTableCells(parentRow) {
  372.    var cells = parentRow.getElementsByTagName('td');
  373.    for (i=0; i<cells.length; i++) {
  374.     switch (i) {
  375.       case 0:
  376.         cells[0].className = globalHightLightColor1;
  377.         break;
  378.       case 1:
  379.         cells[1].className = globalHightLightColor2;
  380.         break;
  381.       case 2:
  382.         cells[2].className = globalHightLightColor3;
  383.         break;
  384.     }
  385.    }
  386.  }
  387.  
  388. /**
  389.  * hightLightLine
  390.  *
  391.  * @param {Node} element
  392.  */
  393.  function hightLightLine(element) {
  394.      if( element != null ) {
  395.          var parentElement = element.parentNode;
  396.  
  397.          if( parentElement != null ) {
  398.              setAllTableCells(parentElement, 'rowSortActive');
  399.              globalHightLightColor = parentElement.className;
  400.              parentElement.className = "rowActive";
  401.          }
  402.      }
  403.  }
  404.  
  405. /**
  406.  * unHightLightLine
  407.  *
  408.  * @param {Node} element
  409.  */
  410.  function unHightLightLine(element) {
  411.      if( element != null ) {
  412.          var parentElement = element.parentNode;
  413.  
  414.          if( parentElement != null ) {
  415.              restorAllTableCells(parentElement);
  416.              parentElement.className = globalHightLightColor;
  417.          }
  418.      }
  419.  }
  420.  
  421. /**
  422.  * redrawResultsTable
  423.  */
  424.  function redrawResultsTable() {   
  425.  
  426.      var element = document.getElementById( "searchResultsDiv" );
  427.  
  428.      if( element != null ) {
  429.  
  430.          var elementHeight = element.scrollHeight;
  431.  
  432.          var parentElement = element.parentNode;
  433.  
  434.          if( parentElement != null ) {
  435.  
  436.              var parentHeight = parentElement.scrollHeight;
  437.  
  438.              var firstElement = document.getElementById( "firstSearchColumn" );
  439.              var secondElement = document.getElementById( "secondSearchColumn" );
  440.              var thirdElement = document.getElementById( "thirdSearchColumn" );
  441.  
  442.              var tableElement = document.getElementById( "searchResultsTable" );
  443.  
  444.             //alert( "x: " + elementHeight + " - y: " + parentHeight );
  445.  
  446.              if( elementHeight >= parentHeight ) {
  447.  
  448.                  // scrollbar present
  449.  
  450.                  if( firstElement != null ) {
  451.                      firstElement.style.width = "140px";
  452.                  }
  453.  
  454.                  if( secondElement != null ) {
  455.                      secondElement.style.width = "511px";
  456.                  }
  457.  
  458.                  if( tableElement != null ) {
  459.                      tableElement.style.height = "";
  460.                  }
  461.  
  462.              } else {
  463.  
  464.                  // no scrollbar
  465.  
  466.                  if( firstElement != null ) {
  467.                      firstElement.style.width = "142px";
  468.                  }
  469.  
  470.                  if( secondElement != null ) {
  471.                      secondElement.style.width = "524px";
  472.                  }
  473.  
  474.                  if( tableElement != null ) {
  475.                      tableElement.style.height = "100%";
  476.                  }
  477.  
  478.              }
  479.          }
  480.      }     
  481.  }
  482.  
  483. function closeSearchDivs() {
  484.   switchLocalSearchDiv(false);
  485.   switchGlobalSearchDiv(false);
  486.   
  487.   var searchesBox = document.getElementById( "searchesBox" );
  488.   if( searchesBox != null ) {
  489.       searchesBox.style.display = "block";
  490.   }  
  491. }
  492.  
  493. function switchLocalSearchDiv(doShow) {
  494.   var elementSearch = document.getElementById('localsearch');
  495.   var elementIFrame = document.getElementById('iframe');
  496.   if (elementSearch != null && elementIFrame != null) {
  497.       if (doShow) {
  498.         elementSearch.style.display = 'block';
  499.         elementIFrame.style.display = 'none';
  500.       }
  501.       else {
  502.         elementSearch.style.display = 'none';
  503.         elementIFrame.style.display = 'block';
  504.       }
  505.   }
  506. }
  507.  
  508. function switchGlobalSearchDiv(doShow) {
  509.   var elementSearch = document.getElementById('globalsearch');
  510.   var elementIFrame = document.getElementById('iframe');
  511.   if (elementSearch != null && elementIFrame != null) {
  512.       if (doShow) {
  513.         elementSearch.style.display = 'block';
  514.         elementIFrame.style.display = 'none';
  515.       }
  516.       else {
  517.         elementSearch.style.display = 'none';
  518.         elementIFrame.style.display = 'block';
  519.       }
  520.  
  521.  
  522.       var resultsElement = document.getElementById('globalsearchresult');
  523.  
  524.       if( resultsElement != null ) {
  525.         resultsElement.style.display = "none";
  526.       }
  527.  
  528.   }
  529.  
  530. }
  531.  
  532. function importXML(filename, type) {
  533. // 1 - local
  534. // 2 - global
  535.     var xmlDoc = null;
  536.     if (document.implementation && document.implementation.createDocument) {
  537.         xmlDoc = document.implementation.createDocument("", "", null);
  538.     }
  539.     else if (window.ActiveXObject) {
  540.         xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  541.      }
  542.     else {
  543.         alert('Your browser can\'t handle this script');
  544.         return;
  545.     }
  546.     xmlDoc.load(filename);
  547.     xmlDoc.setProperty("SelectionLanguage", "XPath");
  548.  
  549.     if (type == 1) {
  550.       xmlDocLocal = xmlDoc;
  551.     }
  552.     else {
  553.       xmlDocGlobal = xmlDoc;
  554.     }
  555.  
  556. }
  557.  
  558. function doLocalSearch() {
  559.   var res = '';
  560.  
  561.   var searchText = "";
  562.   var element = document.getElementById('searchinput');
  563.   if (element != null) {
  564.     searchText = element.value;
  565.     searchText = searchText.toLowerCase();
  566.   }
  567.   if (searchText != "") {
  568.     switchLocalSearchDiv(true);
  569.     switchGlobalSearchDiv(false);
  570.  
  571.     if (xmlDocLocal == null) {
  572.       importXML('localsearch.xml', 1);
  573.     }
  574.  
  575.     var xpath = "//t[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')] | //k[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')] | //l[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')] | //la[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')] | //os[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')]  | //f[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')] ";
  576.  
  577.     var resultNodes = xmlDocLocal.selectNodes(xpath);
  578.     localResultNodes = getResultArray(resultNodes);
  579.     var html = getResultHTML(localResultNodes, 1);
  580.     var searchContent = document.getElementById('searchContentLocal');
  581.  
  582.     if (searchContent != null) {
  583.       searchContent.innerHTML = html;
  584.       resizeIFrame();
  585.       redrawResultsTable();
  586.       //executeInnerHTMLJavaScript( searchContent );
  587.     }
  588.  
  589.     switchLocalSearchDiv(true);
  590.   }
  591. }
  592.  
  593. function getLanguageString() {
  594.   var res = '';
  595.   var langElement;
  596.  
  597.   langElement = document.getElementById('searchInLangDE');
  598.   if (langElement != null && langElement.checked) {
  599.     res += "./parent::*/la[contains(., 'deutsch')] and ";
  600.   }
  601.   langElement = document.getElementById('searchInLangEN');
  602.   if (langElement != null && langElement.checked) {
  603.     res += "./parent::*/la[contains(., 'englisch')] and ";
  604.   }
  605.   langElement = document.getElementById('searchInLangFR');
  606.   if (langElement != null && langElement.checked) {
  607.     res += "./parent::*/la[contains(., 'franz├╢sisch')] and ";
  608.   }
  609.   langElement = document.getElementById('searchInLangES');
  610.   if (langElement != null && langElement.checked) {
  611.     res += "./parent::*/la[contains(., 'spanisch')] and ";
  612.   }
  613.   langElement = document.getElementById('searchInLangIT');
  614.   if (langElement != null && langElement.checked) {
  615.     res += "./parent::*/la[contains(., 'italienisch')] and ";
  616.   }
  617.  
  618.   res = res.substr(0, res.length-4);
  619.  
  620.   if (res != '') {
  621.     res = "((" + res + ") or ./parent::*/la[contains(., 'multilingual')])";
  622.   }
  623.   return res;
  624. }
  625.  
  626. function getOSString() {
  627.   var res = '';
  628.   var osElement;
  629.  
  630.   osElement = document.getElementById('searchInOS95');
  631.   if (osElement != null && osElement.checked) {
  632.     res += "./parent::*/os[contains(., 'Windows 95')] and ";
  633.   }
  634.   osElement = document.getElementById('searchInOS98');
  635.   if (osElement != null && osElement.checked) {
  636.     res += "./parent::*/os[contains(., 'Windows 98')] and ";
  637.   }
  638.   osElement = document.getElementById('searchInOSMe');
  639.   if (osElement != null && osElement.checked) {
  640.     res += "./parent::*/os[contains(., 'Windows Me')] and ";
  641.   }
  642.   osElement = document.getElementById('searchInOS2000');
  643.   if (osElement != null && osElement.checked) {
  644.     res += "./parent::*/os[contains(., 'Windows 2000')] and ";
  645.   }
  646.   osElement = document.getElementById('searchInOS2003');
  647.   if (osElement != null && osElement.checked) {
  648.     res += "./parent::*/os[contains(., 'Windows 2003')] and ";
  649.   }
  650.   osElement = document.getElementById('searchInOSXP');
  651.   if (osElement != null && osElement.checked) {
  652.     res += "./parent::*/os[contains(., 'Windows XP')] and ";
  653.   }
  654.   osElement = document.getElementById('searchInOSXP64');
  655.   if (osElement != null && osElement.checked) {
  656.     res += "./parent::*/os[contains(., 'Windows XP 64')] and ";
  657.   }
  658.   osElement = document.getElementById('searchInOSVista');
  659.   if (osElement != null && osElement.checked) {
  660.     res += "./parent::*/os[contains(., 'Windows Vista')] and ";
  661.   }
  662.   osElement = document.getElementById('searchInOSVista64');
  663.   if (osElement != null && osElement.checked) {
  664.     res += "./parent::*/os[contains(., 'Windows Vista 64')] and ";
  665.   }
  666.  
  667.   res = res.substr(0, res.length-4);
  668.  
  669.   if (res != '') {
  670.     res = "(" + res + ")";
  671.   }
  672.   return res;
  673. }
  674.  
  675. function getGlobalXPathString(searchText) {
  676.   var categoryString = '';
  677.   var res = '';
  678.  
  679.   searchText = searchText.toLowerCase();
  680.  
  681.   // Kategorien
  682.   var catElement = document.getElementById('categoryAll');
  683.   if (catElement != null && !catElement.checked) {
  684.     for (var i=0; i<availableCategories.length; i++) {
  685.       catElement = document.getElementById('category' + i);
  686.       if (catElement != null && catElement.checked) {
  687.         categoryString += "./parent::*[@c='" + availableCategories[i] + "'] or ";
  688.       }
  689.     }
  690.     if (categoryString != '') {
  691.       categoryString = categoryString.substr(0, categoryString.length-3);
  692.       categoryString = "(" + categoryString + ")";
  693.     }
  694.   }
  695.  
  696.   // Sprachen
  697.   var languageString = getLanguageString();
  698.  
  699.   // Betriebsysteme
  700.   var osString = getOSString();
  701.  
  702. //  alert(languageString);
  703.  
  704.   // Ausgaben
  705.   var issueString = '';
  706.   for (var i=0; i<availableIssues.length; i++) {
  707.     var issue = availableIssues[i];
  708.     var year = issue.year;
  709.     var nos = issue.nos;
  710.     var issueElement = document.getElementById('issueyear' + year);
  711.     if (issueElement != null) {
  712.       if (issueElement.checked) {
  713.         // ganzes Jahr
  714.         issueString += "./parent::*/parent::*[@year='" + year + "'] or ";
  715.       }
  716.       else {
  717.         for (var j=0; j<nos.length; j++) {
  718.           var nr = nos[j];
  719.           var issueSubElement = document.getElementById('issueno' + nr + year);
  720.           if (issueSubElement != null && issueSubElement.checked) {
  721.             issueString += "./parent::*/parent::*[@year='" + year + "' and @nr='" + nr + "'] or ";
  722.           }
  723.         }
  724.       }
  725.     }
  726.   }
  727.   if (issueString != '') {
  728.     issueString = issueString.substr(0, issueString.length-3); // -3 damit " or" gefilter wird
  729.     issueString = "(" + issueString + ")";
  730.   }
  731.  
  732.   // im Titel immer suchen
  733.   res += "//t[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')";
  734.   if (categoryString != '') {
  735.     res += " and " + categoryString;
  736.   }
  737.   if (issueString != '') {
  738.     res += " and " + issueString;
  739.   }
  740.   if (languageString != '') {
  741.     res += " and " + languageString;
  742.   }
  743.   if (osString != '') {
  744.     res += " and " + osString;
  745.   }
  746.  
  747.   res += '] | ';
  748.  
  749.   if (document.getElementById('searchInShort').checked) {
  750.       res += "//k[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')";
  751.       if (categoryString != '') {
  752.         res += " and " + categoryString;
  753.       }
  754.       if (issueString != '') {
  755.         res += " and " + issueString;
  756.       }
  757.       if (languageString != '') {
  758.         res += " and " + languageString;
  759.       }
  760.       if (osString != '') {
  761.         res += " and " + osString;
  762.       }
  763.       res += '] | ';
  764.   }
  765.  
  766.   if (document.getElementById('searchInLong').checked) {
  767.       res += "//l[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')";
  768.       if (categoryString != '') {
  769.         res += " and " + categoryString;
  770.       }
  771.       if (issueString != '') {
  772.         res += " and " + issueString;
  773.       }
  774.       if (languageString != '') {
  775.         res += " and " + languageString;
  776.       }
  777.       if (osString != '') {
  778.         res += " and " + osString;
  779.       }
  780.       res += '] | ';
  781.   }
  782.  
  783.   if (document.getElementById('searchInFiles').checked) {
  784.       res += "//f[contains(translate(., '" + bigLetters + "','" + smallLetters + "'),'" + searchText + "')";
  785.       if (categoryString != '') {
  786.         res += " and " + categoryString;
  787.       }
  788.       if (issueString != '') {
  789.         res += " and " + issueString;
  790.       }
  791.       if (languageString != '') {
  792.         res += " and " + languageString;
  793.       }
  794.       if (osString != '') {
  795.         res += " and " + osString;
  796.       }
  797.       res += '] | ';
  798.   }
  799.  
  800.   res = res.substr(0, res.length-2);
  801.  
  802.   return res;
  803. }
  804.  
  805. function searchGlobal_nohistory() {
  806.   var searchText = "";
  807.   var element = document.getElementById('searchglobalinput');
  808.   if (element != null) {
  809.     searchText = element.value;
  810.   }
  811.  
  812.   if (searchText != "") {
  813.     var xpath = getGlobalXPathString(searchText);
  814.     var resultNodes = xmlDocGlobal.selectNodes(xpath);
  815.     globalResultNodes = getResultArray(resultNodes);
  816.     var html = getResultHTML(globalResultNodes, 2);
  817.     var searchContent = document.getElementById('searchContentGlobal');
  818.     if (searchContent != null) {
  819.       searchContent.innerHTML = html;
  820.     }
  821.  
  822.     var resultsElement = document.getElementById('globalsearchresult');
  823.  
  824.     if( resultsElement != null ) {
  825.         resultsElement.style.display = "inline";
  826.     } 
  827.  
  828.     toggleTab_nohistory(2);
  829.  
  830.     if (searchContent != null) {
  831.       resizeIFrame();
  832.       redrawResultsTable();
  833.     }
  834.  
  835.   }
  836. }
  837.  
  838. function searchGlobal() {
  839.   var searchText = "";
  840.   var element = document.getElementById('searchglobalinput');
  841.   if (element != null) {
  842.     searchText = element.value;
  843.   }
  844.  
  845.   if (searchText != "") {
  846.     var xpath = getGlobalXPathString(searchText);
  847.     var resultNodes = xmlDocGlobal.selectNodes(xpath);
  848.     globalResultNodes = getResultArray(resultNodes);
  849.     var html = getResultHTML(globalResultNodes, 2);
  850.     var searchContent = document.getElementById('searchContentGlobal');
  851.     if (searchContent != null) {
  852.       searchContent.innerHTML = html;
  853.     }
  854.  
  855.     var resultsElement = document.getElementById('globalsearchresult');
  856.  
  857.     if( resultsElement != null ) {
  858.         resultsElement.style.display = "inline";
  859.     } 
  860.  
  861.     toggleTab(2);
  862.  
  863.     if (searchContent != null) {
  864.       resizeIFrame();
  865.       redrawResultsTable();
  866.     }
  867.  
  868.   }
  869. }
  870.  
  871. function showDiv(value, divName) {
  872.   var element = document.getElementById(divName);
  873.   if (element != null) {
  874.     if (value) {
  875.       element.style.display = 'block';
  876.     }
  877.     else {
  878.       element.style.display = 'none';
  879.     }
  880.   }
  881. }
  882.  
  883. function showPlaeseWait(value) {
  884.   showDiv(value, 'pleaseWait');
  885. }
  886.  
  887. function showCategoriesDiv(value) {
  888.   showDiv(value, 'searchCategories');
  889. }
  890.  
  891. function showIssuesDiv(value) {
  892.   showDiv(value, 'searchIssues');
  893. }
  894.  
  895. function insertCategoryIntoArray(category) {
  896.   var boolFound = false;
  897.   for (var i=0; i<availableCategories.length; i++) {
  898.     if (availableCategories[i] == category) {
  899.       boolFound = true;
  900.       break;
  901.     }
  902.   }
  903.  
  904.   if (!boolFound) {
  905.     availableCategories.push(category);
  906.   }
  907. }
  908.  
  909. function loadCategories() {
  910.   availableCategories = new Array();
  911.   var category;
  912.   var softwareNodes = xmlDocGlobal.getElementsByTagName('s');
  913.   for (var i=0; i<softwareNodes.length; i++) {
  914.     var softwareNode = softwareNodes[i];
  915.     category = softwareNode.getAttribute('l');
  916.  
  917.     if( category != null && category != "null" ) {
  918.     insertCategoryIntoArray(category);
  919.     }
  920.   }
  921.   availableCategories.sort();
  922. }
  923.  
  924. function insertIssueIntoArray(issueYear, issueNo) {
  925.   var boolFoundYear = false;
  926.   var boolFoundNo = false;
  927.   for (var i=0; i<availableIssues.length; i++) {
  928.     if (availableIssues[i].year == issueYear) {
  929.       boolFoundYear = true;
  930.       for (var j=0; j<availableIssues[i].nos.length; j++) {
  931.         if (availableIssues[i].nos[j] == issueNo) {
  932.           boolFoundNo = true;
  933.           break;
  934.         }
  935.       }
  936.       break;
  937.     }
  938.   }
  939.  
  940.   if (!boolFoundYear) {
  941.     var item = new issueItem();
  942.     item.year = issueYear;
  943.     if (item.nos == null) {
  944.       item.nos = new Array();
  945.     }
  946.     item.nos.push(issueNo);
  947.     availableIssues.push(item);
  948.   }
  949.   else {
  950.     if (!boolFoundNo) {
  951.       var item = availableIssues[i];
  952.       item.nos.push(issueNo);
  953.     }
  954.   }
  955. }
  956.  
  957. function toggleYear(year) {
  958.   var element = document.getElementById('year' + year);
  959.   var elementImage = document.getElementById('plusminus' + year);
  960.   if (element != null) {
  961.     if (element.style.display == 'block') {
  962.       element.style.display = 'none';
  963.       elementImage.src = 'images/tree_plus.gif';
  964.     }
  965.     else {
  966.       element.style.display = 'block';
  967.       elementImage.src = 'images/tree_minus.gif';
  968.     }
  969.   }
  970. }
  971.  
  972. function loadIssues() {
  973.   availableIssues = new Array();
  974.   var issueYear;
  975.   var issueNo;
  976.   var issueNodes = xmlDocGlobal.getElementsByTagName('i');
  977.   for (var i=0; i<issueNodes.length; i++) {
  978.     var issueNode = issueNodes[i];
  979.     issueYear = issueNode.getAttribute('year');
  980.     issueNo = issueNode.getAttribute('nr');
  981.     insertIssueIntoArray(issueYear, issueNo);
  982.   }
  983.   availableCategories.sort();
  984. }
  985.  
  986. function uncheckFirstAllCategory(element) {
  987.   if (element.checked) {
  988.     var catAll = document.getElementById('categoryAll');
  989.     if (catAll != null) {
  990.       catAll.checked = false;
  991.     }
  992.   }
  993. }
  994.  
  995. function uncheckCategories(element) {
  996.   if (element.checked) {
  997.     for (var i=0; i<availableCategories.length; i++) {
  998.         var cat = document.getElementById('category' + i);
  999.         if (cat != null) {
  1000.           cat.checked = false;
  1001.         }
  1002.     }
  1003.   }
  1004. }
  1005.  
  1006. function setCategoriesHTML() {
  1007.   var element = document.getElementById('searchCategories');
  1008.   if (element != null) {
  1009.     var result = '<strong>Lizenzart ausw├ñhlen</strong><br /><br />';
  1010.     result += '<input type="checkbox" id="categoryAll" onclick="uncheckCategories(this);" checked/>Alle<br>';
  1011.     for (var i=0; i<availableCategories.length; i++) {
  1012.       if (availableCategories[i] != '') {
  1013.         result += '<input type="checkbox" id="category' + i + '" onclick="uncheckFirstAllCategory(this);" />' + availableCategories[i] + '<br />';
  1014.       }
  1015.     }
  1016.     element.innerHTML = result;
  1017.   }
  1018. }
  1019.  
  1020. function selectWholeYear(element) {
  1021.   if (element.checked) {
  1022.     var id = element.id;
  1023.     id = id.substr(9);
  1024.     for (var i=0; i<availableIssues.length; i++) {
  1025.       var issue = availableIssues[i];
  1026.       var year = issue.year;
  1027.       var nos = issue.nos;
  1028.       if (year == id) {
  1029.         for (var j=0; j<nos.length; j++) {
  1030.           var tmp = document.getElementById('issueno' + nos[j] + year);
  1031.           tmp.checked = true;
  1032.         }
  1033.       }
  1034.     }
  1035.   }
  1036. }
  1037.  
  1038. function deselectYear(element, year) {
  1039.   if (!element.checked) {
  1040.     var tmp = document.getElementById('issueyear' + year);
  1041.     if (tmp != null) {
  1042.       tmp.checked = false;
  1043.     }
  1044.   }
  1045. }
  1046.  
  1047. function setIssuesHTML() {
  1048.   var issueNoChecked = '';
  1049.   var element = document.getElementById('searchIssues');
  1050.   if (element != null) {
  1051.     var result = '<strong>Ausgaben ausw├ñhlen</strong><br /><br />';
  1052.     for (var i=0; i<availableIssues.length; i++) {
  1053.       var issue = availableIssues[i];
  1054.       var year = issue.year;
  1055.       var nos = issue.nos;
  1056.       var srcLevel1 = 'images/tree_vert_hor.gif';
  1057.       var srcLevel1Next = 'images/tree_vert.gif';
  1058.       if (i == (availableIssues.length-1)) {
  1059.         srcLevel1 = 'images/tree_vert_hor_end.gif';
  1060.         srcLevel1Next = 'images/blank.gif';
  1061.       }
  1062.  
  1063.       result += '<div class="treeview"><img src="' + srcLevel1 + '" /><a href="javascript: void(0);" onclick="toggleYear(\'' + issue.year + '\');"><img src="images/tree_minus.gif" id="plusminus' + issue.year + '" /></a>';
  1064.       result += '<div class="treeContainer"><input class="treeinput" type="checkbox" id="issueyear' + issue.year + '" onclick="selectWholeYear(this);" /><span class="treeline"> ' + year + '</span></div><div class="clearDiv"></div>';
  1065.       result += '<div id="year' + issue.year+ '" style="display: block;">';
  1066.       for (var j=0; j<nos.length; j++) {
  1067.         var srcLevel2 = 'images/tree_vert_hor.gif';
  1068.         if (j == (nos.length-1)) {
  1069.           srcLevel2 = 'images/tree_vert_hor_end.gif';
  1070.         }
  1071.         debug(year + '-' + actYear);
  1072.         debug(nos[j] + '-' + actNo);
  1073.         if (parseInt(year) == parseInt(actYear) && parseInt(nos[j]) == parseInt(actNo)) {
  1074.           issueNoChecked = 'CHECKED';
  1075.         }
  1076.         result += '<div class="treeview"><img src="' + srcLevel1Next + '"><img src="' + srcLevel2 + '"><input class="treeinput" type="checkbox" id="issueno' + nos[j] + year + '" onclick="deselectYear(this, \'' + year + '\');" ' + issueNoChecked + '/><span class="treeline"> ' + nos[j] + '</span></div><div class="clearDiv"></div>';
  1077.       }
  1078.       result += '</div>';
  1079.     }
  1080.  
  1081.     element.innerHTML = result;
  1082.   }
  1083. }
  1084.  
  1085. function doGlobalSearch_nohistory() {
  1086.   var element = document.getElementById('searchglobalinput');
  1087.  
  1088.   var searchesBox = document.getElementById( "searchesBox" );
  1089.  
  1090.   if( searchesBox != null ) {
  1091.       searchesBox.style.display = "none";
  1092.   }
  1093.  
  1094.   if (element != null) {
  1095.     element.value = '';
  1096.   }
  1097.   
  1098.   toggleTab_nohistory(1);
  1099.     
  1100.   var tabResult = document.getElementById('searchContentGlobal');
  1101.   tabResult.innerHTML = '';
  1102.  
  1103.   switchLocalSearchDiv(false);
  1104.   switchGlobalSearchDiv(true);
  1105.   if (xmlDocGlobal == null) {
  1106.     showPlaeseWait(true);
  1107.     importXML('globalsearch.xml', 2);
  1108.     loadCategories();
  1109.     loadIssues();
  1110.     showPlaeseWait(false);
  1111.     if (availableCategories.length > 0) {
  1112.       setCategoriesHTML();
  1113.       showCategoriesDiv(true);
  1114.     }
  1115.     else {
  1116.       showCategoriesDiv(false);
  1117.     }
  1118.     if (availableIssues.length > 0) {
  1119.       setIssuesHTML();
  1120.       showIssuesDiv(true);
  1121.     }
  1122.     else {
  1123.       showIssuesDiv(false);
  1124.     }
  1125.   }
  1126. }
  1127.  
  1128. function doGlobalSearch() {
  1129.   var element = document.getElementById('searchglobalinput');
  1130.  
  1131.   var searchesBox = document.getElementById( "searchesBox" );
  1132.  
  1133.   if( searchesBox != null ) {
  1134.       searchesBox.style.display = "none";
  1135.   }
  1136.  
  1137.   if (element != null) {
  1138.     element.value = '';
  1139.   }
  1140.   
  1141.   toggleTab(1);
  1142.     
  1143.   var tabResult = document.getElementById('searchContentGlobal');
  1144.   tabResult.innerHTML = '';
  1145.  
  1146.   switchLocalSearchDiv(false);
  1147.   switchGlobalSearchDiv(true);
  1148.   if (xmlDocGlobal == null) {
  1149.     showPlaeseWait(true);
  1150.     importXML('globalsearch.xml', 2);
  1151.     loadCategories();
  1152.     loadIssues();
  1153.     showPlaeseWait(false);
  1154.     if (availableCategories.length > 0) {
  1155.       setCategoriesHTML();
  1156.       showCategoriesDiv(true);
  1157.     }
  1158.     else {
  1159.       showCategoriesDiv(false);
  1160.     }
  1161.     if (availableIssues.length > 0) {
  1162.       setIssuesHTML();
  1163.       showIssuesDiv(true);
  1164.     }
  1165.     else {
  1166.       showIssuesDiv(false);
  1167.     }
  1168.   }
  1169. }
  1170.